<%= turbo_frame_tag dom_id(@order, :customer_information), class: "card mb-4 blur-busy" do  %>
  <div class="card-header">
    <h5 class="card-title">
      <%= Spree.t(:customer) %>
    </h5>
    <% if can?(:update_customer, @order) || can?(:update_addresses, @order) %>
      <div class="dropdown ml-auto" id="customer-edit-dropdown">
        <%= link_to_with_icon 'dots', nil, '#', class: 'btn btn-light btn-sm px-2', data: { toggle: 'dropdown', test_id: 'dropdown-toggle' } %>
        <div class="dropdown-menu dropdown-menu-right" >
          <div data-toggle="modal" data-target="#modal">
            <% if can?(:update_customer, @order) && !@order.user.present? %>
              <%= link_to Spree.t('admin.edit_contact_information'), spree.edit_admin_order_contact_information_path(@order), class: 'dropdown-item', data: { turbo_frame: 'dialog_modal' } %>
            <% end %>
            <% if can?(:update_addresses, @order) %>
              <%= link_to Spree.t('admin.edit_shipping_address'), spree.edit_admin_order_shipping_address_path(@order), class: 'dropdown-item', data: { turbo_frame: 'dialog_modal' } if @order.shipping_address.present? %>
              <%= link_to Spree.t('admin.edit_billing_address'), spree.edit_admin_order_billing_address_path(@order), class: 'dropdown-item', data: { turbo_frame: 'dialog_modal' } if @order.billing_address.present? %>
            <% end %>
          </div>
          <% if can?(:update_customer, @order) %>
            <div class="dropdown-divider"></div>
            <% if @order.user.present? %>
              <%= link_to Spree.t('admin.orders.remove_user_from_this_order'), spree.admin_order_user_path(@order), class: 'dropdown-item btn-danger', data: { turbo_method: :delete, turbo_confirm: Spree.t(:are_you_sure), turbo_frame: :_top } %>
            <% else %>
              <%= link_to Spree.t('admin.orders.add_user_to_this_order'), spree.new_admin_order_user_path(@order), class: 'dropdown-item' %>
            <% end %>
          <% end %>
        </div>
      </div>
    <% end %>
  </div>
  <div class="card-body">
    <% unless defined?(current_vendor) && current_vendor %>
      <% unless @order.user.present? %>
        <h6><%= Spree.t(:contact_information) %></h6>
      <% end %>
      <div class='card-text d-flex flex-col'>
        <% if @order.user.present? %>
          <%= render 'spree/admin/shared/user', user: @order.user %>
          <%= render 'spree/admin/orders/user_overview', user: @order.user %>
        <% elsif @order.email.present? %>
          <%= mail_to truncate(@order.email, length: 35), class: 'text-dark with-tip', title: @order.email %>
        <% else %>
          <span class="text-muted">
            <%= Spree.t(:no_email_provided) %>
          </span>
        <% end %>
        <% if !@order.user.present? && can?(:update_customer, @order) %>
          <%= link_to_with_icon 'plus', Spree.t('admin.orders.add_user_to_this_order'), spree.new_admin_order_user_path(@order), class: "btn btn-link mt-3" %>
        <% end %>
      </div>
    <% end %>
    <h6 class="<%= defined?(current_vendor) && current_vendor ? "" : "mt-4" %> font-weight-bold"><%= Spree.t(:shipping_address) %></h6>
    <%= turbo_frame_tag :order_ship_address do %>
      <% if @order.ship_address.present? %>
        <%= render 'spree/admin/shared/address', address: @order.ship_address %>
      <% elsif can?(:update_addresses, @order) %>
        <div data-toggle="modal" data-target="#modal">
          <%= link_to_with_icon 'plus', Spree.t(:new_shipping_address), spree.new_admin_order_shipping_address_path(@order), class: "btn btn-link w-100", data: { turbo_frame: 'dialog_modal' } %>
        </div>
      <% else %>
        <span class="text-muted"><%= Spree.t(:no_shipping_address_available) %></span>
      <% end %>
    <% end %>
    <h6 class="mt-4 font-weight-bold"><%= Spree.t(:billing_address) %></h6>
    <%= turbo_frame_tag :order_bill_address do %>
      <% if @order.shipping_eq_billing_address? && @order.bill_address.present? %>
        <span class="text-muted"><%= Spree.t(:same_as_shipping_address) %></span>
      <% elsif @order.bill_address.present? %>
        <%= render 'spree/admin/shared/address', address: @order.bill_address %>
      <% elsif can?(:update_addresses, @order) %>
        <div data-toggle="modal" data-target="#modal">
          <%= link_to_with_icon 'plus', Spree.t(:new_billing_address), spree.new_admin_order_billing_address_path(@order), class: "btn btn-link w-100", data: { turbo_frame: 'dialog_modal' } %>
        </div>
      <% else %>
        <span class="text-muted"><%= Spree.t(:no_billing_address_available) %></span>
      <% end %>
    <% end %>
  </div>
<% end %>
